
def solve(nums):
    # nums = [6, 4, 3, 3, 2]
    #nums = [3, 3, 3]
    n = len(nums)
    total_sum = sum(nums)

    # Sort descending (already given, but good practice if not guaranteed)
    # nums.sort(reverse=True) # Not needed as per problem description

    # Optimization: Pre-check for impossible cases based on largest element
    if n == 0:
        print("Max m = 0") # Or handle as appropriate
        return 0

    # Backtracking search function
    def can_partition(k, start_idx, current_sum, target_sum, used):
        # Base case: one group successfully formed
        if current_sum == target_sum:
            # Start forming the next group (k-1 remaining)
            # Base case: all groups formed successfully
            if k == 1:
                return True
            # Reset search for the next group
            return can_partition(k - 1, 0, 0, target_sum, used)

        # Pruning: current sum exceeds target
        if current_sum > target_sum:
            return False

        # Pruning: not enough elements left to possibly form remaining groups
        # (This check might be complex to implement correctly here, skip for now)

        # Iterate through elements for the current group
        for i in range(start_idx, n):
            if not used[i]:
                # Try adding nums[i] to the current group
                used[i] = True
                # Recurse: continue building the *current* group
                if can_partition(k, i + 1, current_sum + nums[i], target_sum, used):
                    return True
                # Backtrack
                used[i] = False

                # Optimization: If current_sum is 0, it means we are starting a new group.
                # If placing nums[i] (the first element) fails, then any other
                # identical starting configuration will also fail. Since the array
                # is sorted, we can potentially break early, but let's refine.

                # Optimization: Skip duplicate numbers at the same level
                # If nums[i] didn't lead to a solution, don't try nums[i+1]
                # if it's the same value in the *same position* of choice.
                while i + 1 < n and nums[i] == nums[i+1] and not used[i+1]:
                    i += 1 # Skip the next identical element in this loop iteration

                # Optimization: If current_sum becomes 0 again after backtracking,
                # and we failed to form a group starting with nums[i], we might
                # be able to break if no solution is possible starting with nums[i]
                # for *any* group. This is related to the K-subset partition problem's
                # optimizations.

        # If loop completes without finding a solution for the current state
        return False


    # Iterate through possible values of m from n down to 1
    for m in range(n, 0, -1):
        if total_sum % m == 0:
            target_sum = total_sum // m
            # Check if the largest element fits
            if nums[0] > target_sum:
                continue # This m is impossible

            used = [False] * n
            # Start the search: try to form 'm' groups
            # We initiate by trying to form the first group (k=m)
            # Start index 0, current sum 0
            if can_partition(m, 0, 0, target_sum, used):
                #print(f"Found partition for m = {m}") # For debugging/verification
                # Since we iterate m downwards, the first one we find is the max
                # Here you would typically return m or store it
                max_m = m
                # --- Placeholder for output/return ---
                #print(f"Maximum m = {max_m}")
                return max_m # Return the result

    # If loop completes, m=1 is always possible (the whole array)
    #print("Maximum m = 1")
    return 1


# 测试用例
if __name__ == "__main__":    
    # 测试用例
    test_cases = [
        [6, 4, 3, 3, 2],
        [10, 8, 6, 4, 2],
        [7, 7, 7],
        [5, 4, 3, 2, 1],
        [5, 4, 3, 2],
    ]
    
    for i, test in enumerate(test_cases):
        print(f"测试用例 {i+1} {test}: 最大的m值为 {solve(test)}")